from api_parser import ApiParser
from struct_parser import StructParser
from func_generator import FuncGenerator
from whitelist import OES_WHITELIST


def main():
    # p = StructParser()
    # p.parse('test.h')
    # import json
    # print(json.dumps(p.structs, indent=2))
    # return
    p = StructParser()
    p.parse('oes_base_model.h.i')
    p.parse('oes_packets.h.i')
    p.parse('oes_qry_packets.h.i')
    struct_def = p.structs

    p = ApiParser('../include/oes/oes_api/oes_async_api.h', 'OesAsyncApi_')
    func_def = p.parse()
    p = ApiParser('../include/oes/oes_api/oes_api.h', 'OesApi_')
    func_def.update(p.parse())
    func_def = {k: v for k, v in func_def.items() if k in OES_WHITELIST}
    m = {'pAsyncOrdChannel': 'p_ord_channel', 'pAsyncChannel': 'p_ord_channel', 'pQryChannel': 'p_qry_channel'}
    fg = FuncGenerator('vnoestd', 'TdApi', func_def, struct_def, m,
                       '../vnoes/vnoestd_function_header.h',
                       '../vnoes/vnoestd_function_source.cpp',
                       '../vnoes/vnoestd_bind_source.cpp')
    fg.run()


if __name__ == "__main__":
    main()
